package com.carrot.common.enums;

import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@AllArgsConstructor
@Getter
public enum CellTypeEnum {

    U("1","电压"),
    I("2","电流"),
    R("3","电阻"),
    SOC("4","SOC"),
    SOH("5","SOH"),
    TEMP("6","温度");

    private final String value;

    private final String name;

    /**
     * 根据类型获取名称
     */
    public static String getCellTypeName(String value){
        Map<String, String> enumMap = Stream.of(CellTypeEnum.values())
                .collect(Collectors.toMap(CellTypeEnum::getValue, CellTypeEnum::getName));
        return enumMap.getOrDefault(value,"");
    }

    /**
     * 获取没有枚举的值
     */
    public static List<String> getCellTypeList(){
        List<String> list = Lists.newArrayList();
        CellTypeEnum[] cells = CellTypeEnum.values();
        for (CellTypeEnum cell : cells) {
            list.add(cell.getValue());
        }
        return list;
    }
}
